package cn.zt.service.impl;

import cn.zt.domain.BankCardType;
import cn.zt.domain.Bankcard;
import cn.zt.service.BankCardTypeService;
import cn.zt.service.BankcardService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.zt.domain.BankType;
import cn.zt.service.BankTypeService;
import cn.zt.mapper.BankTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 86182
* @description 针对表【bank_type】的数据库操作Service实现
* @createDate 2024-09-04 15:47:19
*/
@Service
public class BankTypeServiceImpl extends ServiceImpl<BankTypeMapper, BankType>
    implements BankTypeService{
    @Autowired
    private BankcardService bankcardService;
    @Autowired
    private BankCardTypeService bankCardTypeService;
    @Override
    public BankType selectByBankCard(String bankCard) {
        Bankcard bankcard = bankcardService.getOne(Wrappers.<Bankcard>lambdaQuery().eq(Bankcard::getBankCard, bankCard));
        if(bankcard!=null){
            BankCardType bankCardType = bankCardTypeService.getOne(Wrappers.<BankCardType>lambdaQuery().eq(BankCardType::getBankcardId, bankcard.getId()));
            if (bankCardType!=null && bankCardType.getBankTypeId() != null){
                BankType one = this.getOne(Wrappers.<BankType>lambdaQuery().eq(BankType::getId, bankCardType.getBankTypeId()));
                return one;
            }
        }
        return null;
    }
}




